package com.dong.c02_nio;

import java.nio.IntBuffer;

/**
 * <h1>举例buffer的使用</h1>
 *
 * @author : dzj
 * @create: 2020-03-17 20:34
 */
public class BasicBuffer {
    public static void main(String[] args) {
        IntBuffer intBuffer = IntBuffer.allocate(5);
        //存放数据
        intBuffer.put(10);
        intBuffer.put(11);
        intBuffer.put(12);
        intBuffer.put(13);
        intBuffer.put(14);

        //读写切换
        intBuffer.flip();

        while(intBuffer.hasRemaining()) {
            int ii = intBuffer.get();
            System.out.println(ii);
        }
    }
}
